package com.panda.pandawash.view;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.panda.pandawash.R;

/**
 * Created by gaowf on 2017/3/15.
 */

public class InputConfirmDialog extends Dialog {

    public InputConfirmDialog(Context context) {
        super(context);
    }

    public InputConfirmDialog(Context context, int theme) {
        super(context, theme);
    }

    public static class Builder {
        private Context context;
        private TextView cancelText;
        private TextView confirmText;

        private ImageView removeImg;
        private ImageView addImg;
        private EditText editTime;

        public Builder(Context context) {
            this.context = context;
        }

        public InputConfirmDialog create() {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final InputConfirmDialog dialog = new InputConfirmDialog(context, R.style.AppTheme);//SetSafeDialogStyle
            View layout = inflater.inflate(R.layout.dialog_input_confirm, null);
            dialog.addContentView(layout, new WindowManager.LayoutParams(
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT
                    , android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
            dialog.setContentView(layout);

            editTime = (EditText) layout.findViewById(R.id.edit_wash_time);

            removeImg = (ImageView) layout.findViewById(R.id.remove_time_img);
            removeImg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(context, "减少1", Toast.LENGTH_SHORT).show();
                }
            });
            addImg = (ImageView) layout.findViewById(R.id.add_time_img);
            addImg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(context, "增加1", Toast.LENGTH_SHORT).show();
                }
            });


            cancelText = (TextView) layout.findViewById(R.id.set_wash_time_cancel);
            cancelText.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Log.d("gwf_add", "click cancel in dialog");
                    dialog.dismiss();
                }
            });

            confirmText = (TextView) layout.findViewById(R.id.set_wash_time_confirm);
            confirmText.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
//                    Intent intent = new Intent();
//                    intent.setAction(JUMPTOSAFEBOXACTIVITY);
//                    intent.putExtra("msg", "发送确定进入保险箱广播成功！");
//                    context.sendBroadcast(intent);

                    dialog.dismiss();
                }
            });
            return dialog;
        }
    }
}
